package gb.demo.entity;

import lombok.Data;

import java.util.Random;

@Data
public class Email {
    private String email;
    private String code;
    private long date;

    public void newCode() {
        Random random=new Random();
        int code =random.nextInt(8999)+1000;
        this.code= String.valueOf(code);
        this.date=System.currentTimeMillis();
    }
    public boolean verify(String code){
        if(this.code.equals(code))
        {
            long data=System.currentTimeMillis();
            if(data-this.date<300000){
                return true;
            }
            return false;
        }else return false;
    }
}
